package com.rany.day08.demo01;

import java.util.ArrayList;
import java.util.Iterator;

public class ListTest {
    public static void main(String[] args) {
        ArrayList<String> a = new ArrayList<>();
        a.add("a");
        a.add("b");
        a.add("d");
        System.out.println(a);
        a.add(2,"lin");
        System.out.println(a);
        a.remove(1);
        a.remove("d");
        System.out.println(a);
        String s = a.get(1);
        System.out.println(s);
        a.set(0,"Lin");
        System.out.println(a);
        Iterator<String> iterator = a.iterator();
        while (iterator.hasNext()){
            String next = iterator.next();
            System.out.println(next);
        }
        System.out.println("============");
        for (String s1 : a) {
            System.out.println(s1);
        }
    }
}
